package com.wing.wecom.service;/*
package com.wing.wecom.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wing.building.dao.CheckOutApplyDao;
import com.wing.building.dao.DeployApplyDao;
import com.wing.building.dao.LiveApplyDao;
import com.wing.building.model.entity.CheckOutApply;
import com.wing.building.model.entity.DeployApply;
import com.wing.building.model.entity.LiveApply;
import com.wing.building.model.request.CheckOutApplyForm;
import com.wing.building.model.request.DeployApplyForm;
import com.wing.building.model.request.LiveApplyForm;
import com.wing.common.BaseController;
import com.wing.common.exception.BusinessException;
import com.wing.common.utils.LocalDateTimeUtils;
import com.wing.user.dao.*;
import com.wing.user.model.entity.*;
import com.wing.user.model.request.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.Date;

*/
/**
 * 企业微信回调-ContactUserServiceImpl
 *
 * @author
 *//*

@Service
@Slf4j
public class ReceiveServiceImpl implements ReceiveService {

    @Autowired
    private LeaveApplyDao leaveApplyDao;
    @Autowired
    private LeaveApproveDao leaveApproveDao;
    @Autowired
    private LeaveCcRecordDao leaveCcRecordDao;
    @Autowired
    private LeaveTypeDao leaveTypeDao;
    @Autowired
    private HolidayBalanceDao holidayBalanceDao;
    @Autowired
    private HolidayBalanceModifyRecordDao holidayBalanceModifyRecordDao;
    @Autowired
    private ShiftApplyDao shiftApplyDao;
    @Autowired
    private ShiftApproveDao shiftApproveDao;
    @Autowired
    private ShiftCcRecordDao shiftCcRecordDao;
    @Autowired
    private GoOutApplyDao goOutApplyDao;
    @Autowired
    private GoOutApproveDao goOutApproveDao;
    @Autowired
    private GoOutCcRecordDao goOutCcRecordDao;
    @Autowired
    private WorkOvertimeApplyDao workOvertimeApplyDao;
    @Autowired
    private WorkOvertimeApproveDao workOvertimeApproveDao;
    @Autowired
    private WorkOvertimeCcRecordDao workOvertimeCcRecordDao;
    @Autowired
    private PrintApplyDao printApplyDao;
    @Autowired
    private PrintApproveDao printApproveDao;
    @Autowired
    private PrintCcRecordDao printCcRecordDao;
    @Autowired
    private RepairCardApplyDao repairCardApplyDao;
    @Autowired
    private RepairCardApproveDao repairCardApproveDao;
    @Autowired
    private RepairCardCcRecordDao repairCardCcRecordDao;
    @Autowired
    private LiveApplyDao liveApplyDao;
    @Autowired
    private DeployApplyDao deployApplyDao;
    @Autowired
    private CheckOutApplyDao checkOutApplyDao;

    @Override
    @Transactional(readOnly = false)
    public int addLeaveApply(LeaveApplyForm leaveApplyForm) {
        //校验
        LeaveApply leaveApply =new LeaveApply(
                leaveApplyForm.getIsDeleted(),
                leaveApplyForm.getRemark(),
                leaveApplyForm.getLeaveNumber(),
                leaveApplyForm.getUserId(),
                leaveApplyForm.getLeaveTypeId(),
                leaveApplyForm.getTimeScale(),
                leaveApplyForm.getUnitConvert(),
                leaveApplyForm.getStartTime(),
                leaveApplyForm.getEndTime(),
                leaveApplyForm.getStartChoose(),
                leaveApplyForm.getEndChoose(),
                leaveApplyForm.getDuration(),
                leaveApplyForm.getReason(),
                leaveApplyForm.getAnnex(),
                leaveApplyForm.getApproverIds(),
                leaveApplyForm.getCcIds(),
                leaveApplyForm.getSource(),
                leaveApplyForm.getStatus()
        );
        leaveApply.setCreator(leaveApplyForm.getUserId());
        leaveApply.setModifier(leaveApplyForm.getUserId());
        int i = leaveApplyDao.insert(leaveApply);
        if(i > 0){
            String approverIds = leaveApply.getApproverIds(); // 审批人
            String ccIds = leaveApply.getCcIds(); // 抄送人
            // 添加请假审批
            LeaveApprove leaveApprove = new LeaveApprove();
            leaveApprove.setLeaveApplyId(leaveApply.getId()); // 请假申请ID
            if(approverIds.indexOf(",") > 0){
                leaveApprove.setUserId(Long.parseLong(approverIds.split(",")[0])); // 审批人ID
                leaveApprove.setIsFinalApproval(false); // 是否最终审批
            }else{
                leaveApprove.setUserId(Long.parseLong(approverIds)); // 审批人ID
                leaveApprove.setIsFinalApproval(true); // 是否最终审批
            }
            leaveApprove.setStatus(LeaveApprove.Status.stayProcess);
            leaveApprove.setSource(LeaveApprove.Source.enterpriseWeChat);
            leaveApproveDao.insert(leaveApprove);

            // 添加请假抄送记录
            if(ccIds.indexOf(",") > 0){
                for (String ccId : ccIds.split(",")) {
                    LeaveCcRecord leaveCcRecord = new LeaveCcRecord();
                    leaveCcRecord.setLeaveApplyId(leaveApply.getId()); // 请假申请ID
                    leaveCcRecord.setUserId(Long.parseLong(ccId)); // 抄送人ID
                    leaveCcRecord.setSource(LeaveCcRecord.Source.enterpriseWeChat); // 数据来源
                    leaveCcRecordDao.insert(leaveCcRecord);
                }
            }else{
                LeaveCcRecord leaveCcRecord = new LeaveCcRecord();
                leaveCcRecord.setLeaveApplyId(leaveApply.getId()); // 请假申请ID
                leaveCcRecord.setUserId(Long.parseLong(ccIds)); // 抄送人ID
                leaveCcRecord.setSource(LeaveCcRecord.Source.enterpriseWeChat); // 数据来源
                leaveCcRecordDao.insert(leaveCcRecord);
            }
            LeaveType leaveType = leaveTypeDao.selectById(leaveApply.getLeaveTypeId());
            // 修改假期余额
            HolidayBalance holidayBalance = holidayBalanceDao.selectOne(new QueryWrapper<HolidayBalance>()
                    .eq("user_id", leaveApply.getUserId()).eq("leave_type_id", leaveApply.getLeaveTypeId()));
            if(leaveType.getIsQuota()){
                if(holidayBalance.getBalance().compareTo(leaveApply.getDuration()) < 0){
                    // throw new BusinessException(300, "余额不足");
                }else{
                    holidayBalance.setBalance(holidayBalance.getBalance().subtract(leaveApply.getDuration()));
                    holidayBalanceDao.updateById(holidayBalance);
                }
            }
            holidayBalance.setBalance(holidayBalance.getBalance().subtract(leaveApply.getDuration()));
            holidayBalanceDao.updateById(holidayBalance);
            // 添加请假余额修改记录
            HolidayBalanceModifyRecord holidayBalanceModifyRecord = new HolidayBalanceModifyRecord();
            holidayBalanceModifyRecord.setUserId(leaveApply.getUserId());
            holidayBalanceModifyRecord.setLeaveTypeId(leaveApply.getLeaveTypeId());
            holidayBalanceModifyRecord.setOperate("请假");
            holidayBalanceModifyRecord.setChangeDuration("使用"+leaveApply.getDuration()+leaveApply.getTimeScaleDesc());
            holidayBalanceModifyRecordDao.insert(holidayBalanceModifyRecord);
        }
        return i;
    }

    @Override
    @Transactional(readOnly = false)
    public void agreeLeave(String spNo) {
        LeaveApply leaveApply = leaveApplyDao.selectOne(new QueryWrapper<LeaveApply>().eq("leave_number", spNo));
        if(null != leaveApply){
            LeaveApprove leaveApprove = leaveApproveDao.selectOne(new QueryWrapper<LeaveApprove>().eq("leave_apply_id", leaveApply.getId()).eq("status", LeaveApprove.Status.stayProcess));
            leaveApprove.setStatus(LeaveApprove.Status.pass);
            leaveApprove.setApproveTime(LocalDateTimeUtils.convertDateToLDT(new Date())); // 审批时间
            int i = leaveApproveDao.updateById(leaveApprove);
            if(i > 0){
                // 判断是否最终审核人
                if(leaveApprove.getIsFinalApproval()){
                    // 修改请假申请通过
                    leaveApply.setStatus(LeaveApply.Status.pass);
                    leaveApplyDao.updateById(leaveApply);
                }else{
                    String approverIds = leaveApply.getApproverIds();
                    // 添加请假审核
                    LeaveApprove approve = new LeaveApprove();
                    approve.setLeaveApplyId(leaveApply.getId()); // 请假申请ID
                    String[] idsArr = approverIds.split(",");
                    int index = 0;
                    for (int j = 0; j < idsArr.length; j++) {
                        if(leaveApprove.getUserId().equals(idsArr[i])){
                            index = j;
                        }
                    }
                    approve.setUserId(Long.parseLong(idsArr[index+1])); // 审批人ID
                    if(index+1 == idsArr.length-1){ // 是否最终审批
                        approve.setIsFinalApproval(true); // 是否最终审批
                    }else{
                        approve.setIsFinalApproval(false); // 是否最终审批
                    }
                    approve.setStatus(LeaveApprove.Status.stayProcess);
                    approve.setSource(LeaveApprove.Source.enterpriseWeChat);
                    leaveApproveDao.insert(approve);
                }
            }
        }
    }

    @Override
    @Transactional(readOnly = false)
    public void rejectLeave(String spNo) {
        LeaveApply leaveApply = leaveApplyDao.selectOne(new QueryWrapper<LeaveApply>().eq("leave_number", spNo));
        if(null != leaveApply){
            LeaveApprove leaveApprove = leaveApproveDao.selectOne(new QueryWrapper<LeaveApprove>().eq("leave_apply_id", leaveApply.getId()).eq("status", LeaveApprove.Status.stayProcess));
            leaveApprove.setStatus(LeaveApprove.Status.reject);
            leaveApprove.setApproveTime(LocalDateTimeUtils.convertDateToLDT(new Date())); // 审批时间
            int i = leaveApproveDao.updateById(leaveApprove);
            if(i > 0){
                leaveApply.setStatus(LeaveApply.Status.reject);
                leaveApplyDao.updateById(leaveApply);

                // 判断当前请假类型是否有限额
                LeaveType leaveType = leaveTypeDao.selectById(leaveApply.getLeaveTypeId());
                if(leaveType.getIsQuota()){ // 限额
                    // 判断请假类型时间刻度是否一致
                    BigDecimal duration = leaveApply.getDuration();
                    if(!leaveType.getTimeScale().equals(leaveApply.getTimeScale())){
                        if(leaveApply.getTimeScale().equals(LeaveType.TimeScale.day)){
                            // 原来的时间刻度是天，通过单位换算为小时
                            duration = duration.multiply(leaveApply.getUnitConvert()).setScale(1, BigDecimal.ROUND_HALF_UP);
                        }else{
                            // 原来的时间刻度是小时，通过单位换算为天
                            duration = duration.divide(leaveApply.getUnitConvert(), 1, BigDecimal.ROUND_HALF_UP);
                        }
                    }
                    // 修改假期余额
                    HolidayBalance holidayBalance = holidayBalanceDao.selectOne(new QueryWrapper<HolidayBalance>()
                            .eq("user_id", leaveApply.getUserId()).eq("leave_type_id", leaveApply.getLeaveTypeId()));
                    holidayBalance.setBalance(holidayBalance.getBalance().add(duration));
                    holidayBalanceDao.updateById(holidayBalance);
                }

                // 添加请假余额修改记录
                HolidayBalanceModifyRecord holidayBalanceModifyRecord = new HolidayBalanceModifyRecord();
                holidayBalanceModifyRecord.setUserId(leaveApply.getUserId());
                holidayBalanceModifyRecord.setLeaveTypeId(leaveApply.getLeaveTypeId());
                holidayBalanceModifyRecord.setOperate("取消请假");
                holidayBalanceModifyRecord.setChangeDuration("恢复"+leaveApply.getDuration()+leaveApply.getTimeScaleDesc());
                holidayBalanceModifyRecordDao.insert(holidayBalanceModifyRecord);
            }
        }
    }

    @Override
    public void referralLeave(String spNo) {

    }

    @Override
    @Transactional(readOnly = false)
    public void revokeLeave(String spNo) {
        LeaveApply leaveApply = leaveApplyDao.selectOne(new QueryWrapper<LeaveApply>().eq("leave_number", spNo));
        if(null != leaveApply){
            leaveApply.setStatus(LeaveApply.Status.revoke);
            int i = leaveApplyDao.updateById(leaveApply);
            if(i > 0){
                // 判断当前请假类型是否有限额
                LeaveType leaveType = leaveTypeDao.selectById(leaveApply.getLeaveTypeId());
                if(leaveType.getIsQuota()){ // 限额
                    // 判断请假类型时间刻度是否一致
                    BigDecimal duration = leaveApply.getDuration();
                    if(!leaveType.getTimeScale().equals(leaveApply.getTimeScale())){
                        if(leaveApply.getTimeScale().equals(LeaveType.TimeScale.day)){
                            // 原来的时间刻度是天，通过单位换算为小时
                            duration = duration.multiply(leaveApply.getUnitConvert()).setScale(1, BigDecimal.ROUND_HALF_UP);
                        }else{
                            // 原来的时间刻度是小时，通过单位换算为天
                            duration = duration.divide(leaveApply.getUnitConvert(), 1, BigDecimal.ROUND_HALF_UP);
                        }
                    }
                    // 修改假期余额
                    HolidayBalance holidayBalance = holidayBalanceDao.selectOne(new QueryWrapper<HolidayBalance>()
                            .eq("user_id", leaveApply.getUserId()).eq("leave_type_id", leaveApply.getLeaveTypeId()));
                    holidayBalance.setBalance(holidayBalance.getBalance().add(duration));
                    holidayBalanceDao.updateById(holidayBalance);
                }
                // 添加请假余额修改记录
                HolidayBalanceModifyRecord holidayBalanceModifyRecord = new HolidayBalanceModifyRecord();
                holidayBalanceModifyRecord.setUserId(leaveApply.getUserId());
                holidayBalanceModifyRecord.setLeaveTypeId(leaveApply.getLeaveTypeId());
                holidayBalanceModifyRecord.setOperate("取消请假");
                holidayBalanceModifyRecord.setChangeDuration("恢复"+leaveApply.getDuration()+leaveApply.getTimeScaleDesc());
                holidayBalanceModifyRecordDao.insert(holidayBalanceModifyRecord);
            }
        }
    }

    @Override
    @Transactional(readOnly = false)
    public int addShiftApply(ShiftApplyForm shiftApplyForm) {
        //校验
        ShiftApply shiftApply =new ShiftApply(
                shiftApplyForm.getIsDeleted(),
                shiftApplyForm.getRemark(),
                shiftApplyForm.getShiftNumber(),
                shiftApplyForm.getUserId(),
                shiftApplyForm.getShiftUserId(),
                shiftApplyForm.getShiftDate(),
                shiftApplyForm.getAlsoShiftDate(),
                shiftApplyForm.getReason(),
                shiftApplyForm.getAnnex(),
                shiftApplyForm.getApproverIds(),
                shiftApplyForm.getCcIds(),
                shiftApplyForm.getStatus(),
                shiftApplyForm.getSource()
        );
        shiftApply.setCreator(shiftApplyForm.getUserId());
        shiftApply.setModifier(shiftApplyForm.getUserId());
        int i = shiftApplyDao.insert(shiftApply);
        if(i > 0){
            String approverIds = shiftApply.getApproverIds(); // 审批人
            String ccIds = shiftApply.getCcIds(); // 抄送人
            // 添加请假审批
            ShiftApprove shiftApprove = new ShiftApprove();
            shiftApprove.setShiftApplyId(shiftApply.getId()); // 请假申请ID
            if(approverIds.indexOf(",") > 0){
                shiftApprove.setUserId(Long.parseLong(approverIds.split(",")[0])); // 审批人ID
                shiftApprove.setIsFinalApproval(false); // 是否最终审批
            }else{
                shiftApprove.setUserId(Long.parseLong(approverIds)); // 审批人ID
                shiftApprove.setIsFinalApproval(true); // 是否最终审批
            }
            shiftApprove.setStatus(ShiftApprove.Status.stayProcess);
            shiftApprove.setSource(ShiftApprove.Source.enterpriseWeChat);
            shiftApproveDao.insert(shiftApprove);

            // 添加请假抄送记录
            if(ccIds.indexOf(",") > 0){
                for (String ccId : ccIds.split(",")) {
                    ShiftCcRecord shiftCcRecord = new ShiftCcRecord();
                    shiftCcRecord.setShiftApplyId(shiftApply.getId()); // 调班申请ID
                    shiftCcRecord.setUserId(Long.parseLong(ccId)); // 抄送人ID
                    shiftCcRecord.setSource(ShiftCcRecord.Source.enterpriseWeChat); // 数据来源
                    shiftCcRecordDao.insert(shiftCcRecord);
                }
            }else{
                ShiftCcRecord shiftCcRecord = new ShiftCcRecord();
                shiftCcRecord.setShiftApplyId(shiftApply.getId()); // 调班申请ID
                shiftCcRecord.setUserId(Long.parseLong(ccIds)); // 抄送人ID
                shiftCcRecord.setSource(ShiftCcRecord.Source.enterpriseWeChat); // 数据来源
                shiftCcRecordDao.insert(shiftCcRecord);
            }
        }
        return i;
    }

    @Override
    public void agreeShift(String spNo) {
        ShiftApply shiftApply = shiftApplyDao.selectOne(new QueryWrapper<ShiftApply>().eq("shift_number", spNo));
        if(null != shiftApply){
            ShiftApprove shiftApprove = shiftApproveDao.selectOne(new QueryWrapper<ShiftApprove>().eq("shift_apply_id", shiftApply.getId()).eq("status", ShiftApprove.Status.stayProcess));
            shiftApprove.setStatus(ShiftApprove.Status.pass);
            shiftApprove.setApproveTime(LocalDateTimeUtils.convertDateToLDT(new Date())); // 审批时间
            int i = shiftApproveDao.updateById(shiftApprove);
            if(i > 0){
                // 判断是否最终审核人
                if(shiftApprove.getIsFinalApproval()){
                    // 修改调班申请通过
                    shiftApply.setStatus(ShiftApply.Status.pass);
                    shiftApplyDao.updateById(shiftApply);
                }else{
                    String approverIds = shiftApply.getApproverIds();
                    // 添加调班审核
                    ShiftApprove approve = new ShiftApprove();
                    approve.setShiftApplyId(shiftApply.getId()); // 调班申请ID
                    String[] idsArr = approverIds.split(",");
                    int index = 0;
                    for (int j = 0; j < idsArr.length; j++) {
                        if(shiftApprove.getUserId().equals(idsArr[i])){
                            index = j;
                        }
                    }
                    approve.setUserId(Long.parseLong(idsArr[index+1])); // 审批人ID
                    if(index+1 == idsArr.length-1){ // 是否最终审批
                        approve.setIsFinalApproval(true); // 是否最终审批
                    }else{
                        approve.setIsFinalApproval(false); // 是否最终审批
                    }
                    approve.setStatus(ShiftApprove.Status.stayProcess);
                    approve.setSource(ShiftApprove.Source.enterpriseWeChat);
                    shiftApproveDao.insert(approve);
                }
            }
        }
    }

    @Override
    public void rejectShift(String spNo) {
        ShiftApply shiftApply = shiftApplyDao.selectOne(new QueryWrapper<ShiftApply>().eq("shift_number", spNo));
        if(null != shiftApply){
            ShiftApprove shiftApprove = shiftApproveDao.selectOne(new QueryWrapper<ShiftApprove>().eq("shift_apply_id", shiftApply.getId()).eq("status", ShiftApprove.Status.stayProcess));
            shiftApprove.setStatus(ShiftApprove.Status.reject);
            shiftApprove.setApproveTime(LocalDateTimeUtils.convertDateToLDT(new Date())); // 审批时间
            int i = shiftApproveDao.updateById(shiftApprove);
            if(i > 0){
                shiftApply.setStatus(ShiftApply.Status.reject);
                shiftApplyDao.updateById(shiftApply);
            }
        }
    }

    @Override
    public void revokeShift(String spNo) {
        ShiftApply shiftApply = shiftApplyDao.selectOne(new QueryWrapper<ShiftApply>().eq("shift_number", spNo));
        if(null != shiftApply){
            shiftApply.setStatus(ShiftApply.Status.revoke);
            shiftApplyDao.updateById(shiftApply);
        }
    }

    @Override
    public int addGoOutApply(GoOutApplyForm goOutApplyForm) {
        //校验
        GoOutApply goOutApply =new GoOutApply(
                goOutApplyForm.getIsDeleted(),
                goOutApplyForm.getRemark(),
                goOutApplyForm.getGoOutNumber(),
                goOutApplyForm.getUserId(),
                goOutApplyForm.getStartTime(),
                goOutApplyForm.getEndTime(),
                goOutApplyForm.getDuration(),
                goOutApplyForm.getAdress(),
                goOutApplyForm.getReason(),
                goOutApplyForm.getAnnex(),
                goOutApplyForm.getApproverIds(),
                goOutApplyForm.getCcIds(),
                goOutApplyForm.getStatus(),
                goOutApplyForm.getSource()
        );
        goOutApply.setCreator(goOutApplyForm.getUserId());
        goOutApply.setModifier(goOutApplyForm.getUserId());
        int i = goOutApplyDao.insert(goOutApply);
        if(i > 0){
            String approverIds = goOutApply.getApproverIds(); // 审批人
            String ccIds = goOutApply.getCcIds(); // 抄送人
            // 添加外出审批
            GoOutApprove goOutApprove = new GoOutApprove();
            goOutApprove.setGoOutApplyId(goOutApply.getId()); // 外出申请ID
            if(approverIds.indexOf(",") > 0){
                goOutApprove.setUserId(Long.parseLong(approverIds.split(",")[0])); // 审批人ID
                goOutApprove.setIsFinalApproval(false); // 是否最终审批
            }else{
                goOutApprove.setUserId(Long.parseLong(approverIds)); // 审批人ID
                goOutApprove.setIsFinalApproval(true); // 是否最终审批
            }
            goOutApprove.setStatus(GoOutApprove.Status.stayProcess);
            goOutApprove.setSource(GoOutApprove.Source.enterpriseWeChat);
            goOutApproveDao.insert(goOutApprove);

            // 添加外出抄送记录
            if(ccIds.indexOf(",") > 0){
                for (String ccId : ccIds.split(",")) {
                    GoOutCcRecord goOutCcRecord = new GoOutCcRecord();
                    goOutCcRecord.setGoOutApplyId(goOutApply.getId()); // 外出申请ID
                    goOutCcRecord.setUserId(Long.parseLong(ccId)); // 抄送人ID
                    goOutCcRecord.setSource(GoOutCcRecord.Source.enterpriseWeChat); // 数据来源
                    goOutCcRecordDao.insert(goOutCcRecord);
                }
            }else{
                GoOutCcRecord goOutCcRecord = new GoOutCcRecord();
                goOutCcRecord.setGoOutApplyId(goOutApply.getId()); // 外出申请ID
                goOutCcRecord.setUserId(Long.parseLong(ccIds)); // 抄送人ID
                goOutCcRecord.setSource(GoOutCcRecord.Source.enterpriseWeChat); // 数据来源
                goOutCcRecordDao.insert(goOutCcRecord);
            }
        }
        return i;
    }

    @Override
    public void agreeGoOut(String spNo) {
        GoOutApply goOutApply = goOutApplyDao.selectOne(new QueryWrapper<GoOutApply>().eq("go_out_number", spNo));
        if(null != goOutApply){
            GoOutApprove goOutApprove = goOutApproveDao.selectOne(new QueryWrapper<GoOutApprove>().eq("go_out_apply_id", goOutApply.getId()).eq("status", GoOutApprove.Status.stayProcess));
            goOutApprove.setStatus(GoOutApprove.Status.pass);
            goOutApprove.setApproveTime(LocalDateTimeUtils.convertDateToLDT(new Date())); // 审批时间
            int i = goOutApproveDao.updateById(goOutApprove);
            if(i > 0){
                // 判断是否最终审核人
                if(goOutApprove.getIsFinalApproval()){
                    // 修改外出申请通过
                    goOutApply.setStatus(GoOutApply.Status.pass);
                    goOutApplyDao.updateById(goOutApply);
                }else{
                    String approverIds = goOutApply.getApproverIds();
                    // 添加外出审核
                    GoOutApprove approve = new GoOutApprove();
                    approve.setGoOutApplyId(goOutApply.getId()); // 外出申请ID
                    String[] idsArr = approverIds.split(",");
                    int index = 0;
                    for (int j = 0; j < idsArr.length; j++) {
                        if(goOutApprove.getUserId().equals(idsArr[i])){
                            index = j;
                        }
                    }
                    approve.setUserId(Long.parseLong(idsArr[index+1])); // 审批人ID
                    if(index+1 == idsArr.length-1){ // 是否最终审批
                        approve.setIsFinalApproval(true); // 是否最终审批
                    }else{
                        approve.setIsFinalApproval(false); // 是否最终审批
                    }
                    approve.setStatus(GoOutApprove.Status.stayProcess);
                    approve.setSource(GoOutApprove.Source.enterpriseWeChat);
                    goOutApproveDao.insert(approve);
                }
            }
        }
    }

    @Override
    public void rejectGoOut(String spNo) {
        GoOutApply goOutApply = goOutApplyDao.selectOne(new QueryWrapper<GoOutApply>().eq("go_out_number", spNo));
        if(null != goOutApply){
            GoOutApprove goOutApprove = goOutApproveDao.selectOne(new QueryWrapper<GoOutApprove>().eq("go_out_apply_id", goOutApply.getId()).eq("status", GoOutApprove.Status.stayProcess));
            goOutApprove.setStatus(GoOutApprove.Status.reject);
            goOutApprove.setApproveTime(LocalDateTimeUtils.convertDateToLDT(new Date())); // 审批时间
            int i = goOutApproveDao.updateById(goOutApprove);
            if(i > 0){
                goOutApply.setStatus(GoOutApply.Status.reject);
                goOutApplyDao.updateById(goOutApply);
            }
        }
    }

    @Override
    public void revokeGoOut(String spNo) {
        GoOutApply goOutApply = goOutApplyDao.selectOne(new QueryWrapper<GoOutApply>().eq("go_out_number", spNo));
        if(null != goOutApply){
            goOutApply.setStatus(GoOutApply.Status.revoke);
            goOutApplyDao.updateById(goOutApply);
        }
    }

    @Override
    public int addWorkOvertimeApply(WorkOvertimeApplyForm workOvertimeApplyForm) {
        //校验
        WorkOvertimeApply workOvertimeApply =new WorkOvertimeApply(
                workOvertimeApplyForm.getIsDeleted(),
                workOvertimeApplyForm.getRemark(),
                workOvertimeApplyForm.getWorkOvertimeNumber(),
                workOvertimeApplyForm.getUserId(),
                workOvertimeApplyForm.getStartTime(),
                workOvertimeApplyForm.getEndTime(),
                workOvertimeApplyForm.getDuration(),
                workOvertimeApplyForm.getReason(),
                workOvertimeApplyForm.getAnnex(),
                workOvertimeApplyForm.getApproverIds(),
                workOvertimeApplyForm.getCcIds(),
                workOvertimeApplyForm.getStatus(),
                workOvertimeApplyForm.getSource()
        );
        workOvertimeApply.setCreator(workOvertimeApplyForm.getUserId());
        workOvertimeApply.setModifier(workOvertimeApplyForm.getUserId());
        int i = workOvertimeApplyDao.insert(workOvertimeApply);
        if(i > 0){
            String approverIds = workOvertimeApply.getApproverIds(); // 审批人
            String ccIds = workOvertimeApply.getCcIds(); // 抄送人
            // 添加外出审批
            WorkOvertimeApprove workOvertimeApprove = new WorkOvertimeApprove();
            workOvertimeApprove.setWorkOvertimeApplyId(workOvertimeApply.getId()); // 外出申请ID
            if(approverIds.indexOf(",") > 0){
                workOvertimeApprove.setUserId(Long.parseLong(approverIds.split(",")[0])); // 审批人ID
                workOvertimeApprove.setIsFinalApproval(false); // 是否最终审批
            }else{
                workOvertimeApprove.setUserId(Long.parseLong(approverIds)); // 审批人ID
                workOvertimeApprove.setIsFinalApproval(true); // 是否最终审批
            }
            workOvertimeApprove.setStatus(WorkOvertimeApprove.Status.stayProcess);
            workOvertimeApprove.setSource(WorkOvertimeApprove.Source.enterpriseWeChat);
            workOvertimeApproveDao.insert(workOvertimeApprove);

            // 添加外出抄送记录
            if(ccIds.indexOf(",") > 0){
                for (String ccId : ccIds.split(",")) {
                    WorkOvertimeCcRecord workOvertimeCcRecord = new WorkOvertimeCcRecord();
                    workOvertimeCcRecord.setWorkOvertimeApplyId(workOvertimeApply.getId()); // 外出申请ID
                    workOvertimeCcRecord.setUserId(Long.parseLong(ccId)); // 抄送人ID
                    workOvertimeCcRecord.setSource(WorkOvertimeCcRecord.Source.enterpriseWeChat); // 数据来源
                    workOvertimeCcRecordDao.insert(workOvertimeCcRecord);
                }
            }else{
                WorkOvertimeCcRecord workOvertimeCcRecord = new WorkOvertimeCcRecord();
                workOvertimeCcRecord.setWorkOvertimeApplyId(workOvertimeApply.getId()); // 外出申请ID
                workOvertimeCcRecord.setUserId(Long.parseLong(ccIds)); // 抄送人ID
                workOvertimeCcRecord.setSource(WorkOvertimeCcRecord.Source.enterpriseWeChat); // 数据来源
                workOvertimeCcRecordDao.insert(workOvertimeCcRecord);
            }
        }
        return i;
    }

    @Override
    public void agreeWorkOvertime(String spNo) {
        WorkOvertimeApply workOvertimeApply = workOvertimeApplyDao.selectOne(new QueryWrapper<WorkOvertimeApply>().eq("work_overtime_number", spNo));
        if(null != workOvertimeApply){
            WorkOvertimeApprove workOvertimeApprove = workOvertimeApproveDao.selectOne(new QueryWrapper<WorkOvertimeApprove>().eq("work_overtime_apply_id", workOvertimeApply.getId()).eq("status", WorkOvertimeApprove.Status.stayProcess));
            workOvertimeApprove.setStatus(WorkOvertimeApprove.Status.pass);
            workOvertimeApprove.setApproveTime(LocalDateTimeUtils.convertDateToLDT(new Date())); // 审批时间
            int i = workOvertimeApproveDao.updateById(workOvertimeApprove);
            if(i > 0){
                // 判断是否最终审核人
                if(workOvertimeApprove.getIsFinalApproval()){
                    // 修改加班申请通过
                    workOvertimeApply.setStatus(WorkOvertimeApply.Status.pass);
                    workOvertimeApplyDao.updateById(workOvertimeApply);
                }else{
                    String approverIds = workOvertimeApply.getApproverIds();
                    // 添加加班审核
                    WorkOvertimeApprove approve = new WorkOvertimeApprove();
                    approve.setWorkOvertimeApplyId(workOvertimeApply.getId()); // 加班申请ID
                    String[] idsArr = approverIds.split(",");
                    int index = 0;
                    for (int j = 0; j < idsArr.length; j++) {
                        if(workOvertimeApprove.getUserId().equals(idsArr[i])){
                            index = j;
                        }
                    }
                    approve.setUserId(Long.parseLong(idsArr[index+1])); // 审批人ID
                    if(index+1 == idsArr.length-1){ // 是否最终审批
                        approve.setIsFinalApproval(true); // 是否最终审批
                    }else{
                        approve.setIsFinalApproval(false); // 是否最终审批
                    }
                    approve.setStatus(WorkOvertimeApprove.Status.stayProcess);
                    approve.setSource(WorkOvertimeApprove.Source.enterpriseWeChat);
                    workOvertimeApproveDao.insert(approve);
                }
            }
        }
    }

    @Override
    public void rejectWorkOvertime(String spNo) {
        WorkOvertimeApply workOvertimeApply = workOvertimeApplyDao.selectOne(new QueryWrapper<WorkOvertimeApply>().eq("work_overtime_number", spNo));
        if(null != workOvertimeApply){
            WorkOvertimeApprove workOvertimeApprove = workOvertimeApproveDao.selectOne(new QueryWrapper<WorkOvertimeApprove>().eq("work_overtime_apply_id", workOvertimeApply.getId()).eq("status", WorkOvertimeApprove.Status.stayProcess));
            workOvertimeApprove.setStatus(WorkOvertimeApprove.Status.reject);
            workOvertimeApprove.setApproveTime(LocalDateTimeUtils.convertDateToLDT(new Date())); // 审批时间
            int i = workOvertimeApproveDao.updateById(workOvertimeApprove);
            if(i > 0){
                workOvertimeApply.setStatus(WorkOvertimeApply.Status.reject);
                workOvertimeApplyDao.updateById(workOvertimeApply);
            }
        }
    }

    @Override
    public void revokeWorkOvertime(String spNo) {
        WorkOvertimeApply workOvertimeApply = workOvertimeApplyDao.selectOne(new QueryWrapper<WorkOvertimeApply>().eq("work_overtime_number", spNo));
        if(null != workOvertimeApply){
            workOvertimeApply.setStatus(WorkOvertimeApply.Status.revoke);
            workOvertimeApplyDao.updateById(workOvertimeApply);
        }
    }

    @Override
    public int addPrintApply(PrintApplyForm printApplyForm) {
        //校验
        PrintApply printApply =new PrintApply(
                printApplyForm.getIsDeleted(),
                printApplyForm.getRemark(),
                printApplyForm.getPrintNumber(),
                printApplyForm.getUserId(),
                printApplyForm.getReason(),
                printApplyForm.getSealType(),
                printApplyForm.getName(),
                printApplyForm.getNumber(),
                printApplyForm.getUsePrintDate(),
                printApplyForm.getAnnex(),
                printApplyForm.getApproverIds(),
                printApplyForm.getCcIds(),
                printApplyForm.getStatus(),
                printApplyForm.getSource()
        );
        printApply.setCreator(printApplyForm.getUserId());
        printApply.setModifier(printApplyForm.getUserId());
        int i = printApplyDao.insert(printApply);
        if(i > 0){
            String approverIds = printApply.getApproverIds(); // 审批人
            String ccIds = printApply.getCcIds(); // 抄送人
            // 添加用印审批
            PrintApprove printApprove = new PrintApprove();
            printApprove.setPrintApplyId(printApply.getId()); // 用印申请ID
            if(approverIds.indexOf(",") > 0){
                printApprove.setUserId(Long.parseLong(approverIds.split(",")[0])); // 审批人ID
                printApprove.setIsFinalApproval(false); // 是否最终审批
            }else{
                printApprove.setUserId(Long.parseLong(approverIds)); // 审批人ID
                printApprove.setIsFinalApproval(true); // 是否最终审批
            }
            printApprove.setStatus(PrintApprove.Status.stayProcess);
            printApprove.setSource(PrintApprove.Source.enterpriseWeChat);
            printApproveDao.insert(printApprove);

            // 添加请假抄送记录
            if(ccIds.indexOf(",") > 0){
                for (String ccId : ccIds.split(",")) {
                    PrintCcRecord printCcRecord = new PrintCcRecord();
                    printCcRecord.setPrintApplyId(printApply.getId()); // 用印申请ID
                    printCcRecord.setUserId(Long.parseLong(ccId)); // 抄送人ID
                    printCcRecord.setSource(PrintCcRecord.Source.enterpriseWeChat); // 数据来源
                    printCcRecordDao.insert(printCcRecord);
                }
            }else{
                PrintCcRecord printCcRecord = new PrintCcRecord();
                printCcRecord.setPrintApplyId(printApply.getId()); // 用印申请ID
                printCcRecord.setUserId(Long.parseLong(ccIds)); // 抄送人ID
                printCcRecord.setSource(PrintCcRecord.Source.enterpriseWeChat); // 数据来源
                printCcRecordDao.insert(printCcRecord);
            }
        }
        return i;
    }

    @Override
    public void agreePrint(String spNo) {
        PrintApply printApply = printApplyDao.selectOne(new QueryWrapper<PrintApply>().eq("print_number", spNo));
        if(null != printApply){
            PrintApprove printApprove = printApproveDao.selectOne(new QueryWrapper<PrintApprove>().eq("print_apply_id", printApply.getId()).eq("status", PrintApprove.Status.stayProcess));
            printApprove.setStatus(PrintApprove.Status.pass);
            printApprove.setApproveTime(LocalDateTimeUtils.convertDateToLDT(new Date())); // 审批时间
            int i = printApproveDao.updateById(printApprove);
            if(i > 0){
                // 判断是否最终审核人
                if(printApprove.getIsFinalApproval()){
                    // 修改用印申请通过
                    printApply.setStatus(PrintApply.Status.pass);
                    printApplyDao.updateById(printApply);
                }else{
                    String approverIds = printApply.getApproverIds();
                    // 添加用印审核
                    PrintApprove approve = new PrintApprove();
                    approve.setPrintApplyId(printApply.getId()); // 用印申请ID
                    String[] idsArr = approverIds.split(",");
                    int index = 0;
                    for (int j = 0; j < idsArr.length; j++) {
                        if(printApprove.getUserId().equals(idsArr[i])){
                            index = j;
                        }
                    }
                    approve.setUserId(Long.parseLong(idsArr[index+1])); // 审批人ID
                    if(index+1 == idsArr.length-1){ // 是否最终审批
                        approve.setIsFinalApproval(true); // 是否最终审批
                    }else{
                        approve.setIsFinalApproval(false); // 是否最终审批
                    }
                    approve.setStatus(PrintApprove.Status.stayProcess);
                    approve.setSource(PrintApprove.Source.enterpriseWeChat);
                    printApproveDao.insert(approve);
                }
            }
        }
    }

    @Override
    public void rejectPrint(String spNo) {
        PrintApply printApply = printApplyDao.selectOne(new QueryWrapper<PrintApply>().eq("print_number", spNo));
        if(null != printApply){
            PrintApprove printApprove = printApproveDao.selectOne(new QueryWrapper<PrintApprove>().eq("print_apply_id", printApply.getId()).eq("status", PrintApprove.Status.stayProcess));
            printApprove.setStatus(PrintApprove.Status.reject);
            printApprove.setApproveTime(LocalDateTimeUtils.convertDateToLDT(new Date())); // 审批时间
            int i = printApproveDao.updateById(printApprove);
            if(i > 0){
                printApply.setStatus(PrintApply.Status.reject);
                printApplyDao.updateById(printApply);
            }
        }
    }

    @Override
    public void revokePrint(String spNo) {
        PrintApply printApply = printApplyDao.selectOne(new QueryWrapper<PrintApply>().eq("print_number", spNo));
        if(null != printApply){
            printApply.setStatus(PrintApply.Status.revoke);
            printApplyDao.updateById(printApply);
        }
    }

    @Override
    public int addRepairCardApply(RepairCardApplyForm repairCardApplyForm) {
        //校验
        RepairCardApply repairCardApply =new RepairCardApply(
                repairCardApplyForm.getIsDeleted(),
                repairCardApplyForm.getRemark(),
                repairCardApplyForm.getRepairCardNumber(),
                repairCardApplyForm.getUserId(),
                repairCardApplyForm.getAbnormal(),
                repairCardApplyForm.getRepairCardTime(),
                repairCardApplyForm.getReason(),
                repairCardApplyForm.getAnnex(),
                repairCardApplyForm.getApproverIds(),
                repairCardApplyForm.getCcIds(),
                repairCardApplyForm.getStatus(),
                repairCardApplyForm.getSource()
        );
        repairCardApply.setCreator(repairCardApplyForm.getUserId());
        repairCardApply.setModifier(repairCardApplyForm.getUserId());

        int i = repairCardApplyDao.insert(repairCardApply);
        if(i > 0){
            String approverIds = repairCardApply.getApproverIds(); // 审批人
            String ccIds = repairCardApply.getCcIds(); // 抄送人
            // 添加补卡审批
            RepairCardApprove repairCardApprove = new RepairCardApprove();
            repairCardApprove.setRepairCardApplyId(repairCardApply.getId()); // 补卡申请ID
            if(approverIds.indexOf(",") > 0){
                repairCardApprove.setUserId(Long.parseLong(approverIds.split(",")[0])); // 审批人ID
                repairCardApprove.setIsFinalApproval(false); // 是否最终审批
            }else{
                repairCardApprove.setUserId(Long.parseLong(approverIds)); // 审批人ID
                repairCardApprove.setIsFinalApproval(true); // 是否最终审批
            }
            repairCardApprove.setStatus(RepairCardApprove.Status.stayProcess);
            repairCardApprove.setSource(RepairCardApprove.Source.enterpriseWeChat);
            repairCardApproveDao.insert(repairCardApprove);

            // 添加请假抄送记录
            if(ccIds.indexOf(",") > 0){
                for (String ccId : ccIds.split(",")) {
                    RepairCardCcRecord repairCardCcRecord = new RepairCardCcRecord();
                    repairCardCcRecord.setRepairCardApplyId(repairCardApply.getId()); // 补卡申请ID
                    repairCardCcRecord.setUserId(Long.parseLong(ccId)); // 抄送人ID
                    repairCardCcRecord.setSource(RepairCardCcRecord.Source.enterpriseWeChat); // 数据来源
                    repairCardCcRecordDao.insert(repairCardCcRecord);
                }
            }else{
                RepairCardCcRecord repairCardCcRecord = new RepairCardCcRecord();
                repairCardCcRecord.setRepairCardApplyId(repairCardApply.getId()); // 补卡申请ID
                repairCardCcRecord.setUserId(Long.parseLong(ccIds)); // 抄送人ID
                repairCardCcRecord.setSource(RepairCardCcRecord.Source.enterpriseWeChat); // 数据来源
                repairCardCcRecordDao.insert(repairCardCcRecord);
            }
        }
        return i;
    }

    @Override
    public void agreeRepairCard(String spNo) {
        RepairCardApply repairCardApply = repairCardApplyDao.selectOne(new QueryWrapper<RepairCardApply>().eq("repair_card_number", spNo));
        if(null != repairCardApply){
            RepairCardApprove repairCardApprove = repairCardApproveDao.selectOne(new QueryWrapper<RepairCardApprove>().eq("repair_card_apply_id", repairCardApply.getId()).eq("status", RepairCardApprove.Status.stayProcess));
            repairCardApprove.setStatus(RepairCardApprove.Status.pass);
            repairCardApprove.setApproveTime(LocalDateTimeUtils.convertDateToLDT(new Date())); // 审批时间
            int i = repairCardApproveDao.updateById(repairCardApprove);
            if(i > 0){
                // 判断是否最终审核人
                if(repairCardApprove.getIsFinalApproval()){
                    // 修改补卡申请通过
                    repairCardApply.setStatus(RepairCardApply.Status.pass);
                    repairCardApplyDao.updateById(repairCardApply);
                }else{
                    String approverIds = repairCardApply.getApproverIds();
                    // 添加补卡审核
                    RepairCardApprove approve = new RepairCardApprove();
                    approve.setRepairCardApplyId(repairCardApply.getId()); // 补卡申请ID
                    String[] idsArr = approverIds.split(",");
                    int index = 0;
                    for (int j = 0; j < idsArr.length; j++) {
                        if(repairCardApprove.getUserId().equals(idsArr[i])){
                            index = j;
                        }
                    }
                    approve.setUserId(Long.parseLong(idsArr[index+1])); // 审批人ID
                    if(index+1 == idsArr.length-1){ // 是否最终审批
                        approve.setIsFinalApproval(true); // 是否最终审批
                    }else{
                        approve.setIsFinalApproval(false); // 是否最终审批
                    }
                    approve.setStatus(RepairCardApprove.Status.stayProcess);
                    approve.setSource(RepairCardApprove.Source.enterpriseWeChat);
                    repairCardApproveDao.insert(approve);
                }
            }
        }
    }

    @Override
    public void rejectRepairCard(String spNo) {
        RepairCardApply repairCardApply = repairCardApplyDao.selectOne(new QueryWrapper<RepairCardApply>().eq("repair_card_number", spNo));
        if(null != repairCardApply){
            RepairCardApprove repairCardApprove = repairCardApproveDao.selectOne(new QueryWrapper<RepairCardApprove>().eq("repair_card_apply_id", repairCardApply.getId()).eq("status", RepairCardApprove.Status.stayProcess));
            repairCardApprove.setStatus(RepairCardApprove.Status.reject);
            repairCardApprove.setApproveTime(LocalDateTimeUtils.convertDateToLDT(new Date())); // 审批时间
            int i = repairCardApproveDao.updateById(repairCardApprove);
            if(i > 0){
                repairCardApply.setStatus(RepairCardApply.Status.reject);
                repairCardApplyDao.updateById(repairCardApply);
            }
        }
    }

    @Override
    public void revokeRepairCard(String spNo) {
        RepairCardApply repairCardApply = repairCardApplyDao.selectOne(new QueryWrapper<RepairCardApply>().eq("repair_card_number", spNo));
        if(null != repairCardApply){
            repairCardApply.setStatus(RepairCardApply.Status.revoke);
            repairCardApplyDao.updateById(repairCardApply);
        }
    }

    @Override
    public int addLiveApply(LiveApplyForm liveApplyForm) {
        //校验
        LiveApply liveApply =new LiveApply(
                liveApplyForm.getCreator(),
                liveApplyForm.getModifier(),
                liveApplyForm.getIsDeleted(),
                liveApplyForm.getRemark(),
                liveApplyForm.getCode(),
                liveApplyForm.getCompanyId(),
                liveApplyForm.getDepartmentId(),
                liveApplyForm.getPostId(),
                liveApplyForm.getUserId(),
                liveApplyForm.getSex(),
                liveApplyForm.getAge(),
                liveApplyForm.getMaritalStatus(),
                liveApplyForm.getLivingTime(),
                liveApplyForm.getAuditStatus(),
                liveApplyForm.getStatus(),
                liveApplyForm.getAssignorId(),
                liveApplyForm.getAuditReply(),
                liveApplyForm.getSource()
        );
        liveApply.setCreator(Long.parseLong(liveApplyForm.getUserId()));
        liveApply.setModifier(Long.parseLong(liveApplyForm.getUserId()));
        liveApply.setUserId(liveApplyForm.getUserId());
        return liveApplyDao.insert(liveApply);
    }

    @Override
    public void agreeLive(String spNo) {
        LiveApply liveApply = liveApplyDao.selectOne(new QueryWrapper<LiveApply>().eq("code", spNo));
        if(null != liveApply){
            liveApply.setStatus(LiveApply.Status.submitted); // 审核通过修改状态为已提交
            liveApplyDao.updateById(liveApply);
        }
    }

    @Override
    public void rejectLive(String spNo) {
        LiveApply liveApply = liveApplyDao.selectOne(new QueryWrapper<LiveApply>().eq("code", spNo));
        if(null != liveApply){
            liveApply.setStatus(LiveApply.Status.revoked);
            liveApplyDao.updateById(liveApply);
        }
    }

    @Override
    public void revokeLive(String spNo) {
        LiveApply liveApply = liveApplyDao.selectOne(new QueryWrapper<LiveApply>().eq("code", spNo));
        if(null != liveApply){
            liveApply.setStatus(LiveApply.Status.revoked);
            liveApplyDao.updateById(liveApply);
        }
    }

    @Override
    public int addDeployApply(DeployApplyForm deployApplyForm) {
        //校验
        DeployApply deployApply =new DeployApply(
                deployApplyForm.getCreator(),
                deployApplyForm.getModifier(),
                deployApplyForm.getIsDeleted(),
                deployApplyForm.getRemark(),
                deployApplyForm.getCode(),
                deployApplyForm.getUserId(),
                deployApplyForm.getStatus(),
                deployApplyForm.getSex(),
                deployApplyForm.getAge(),
                deployApplyForm.getMaritalStatus(),
                deployApplyForm.getBuildingId(),
                deployApplyForm.getFloorId(),
                deployApplyForm.getApplyRoomCategoryId(),
                deployApplyForm.getApplyRoomSnId(),
                deployApplyForm.getApplyBedSnId(),
                deployApplyForm.getRoomCategoryId(),
                deployApplyForm.getRoomSnId(),
                deployApplyForm.getBedSnId(),
                deployApplyForm.getLivingTime(),
                deployApplyForm.getAuditReply(),
                deployApplyForm.getAuditStatus(),
                deployApplyForm.getBuildingId(),
                deployApplyForm.getFloorId(),
                deployApplyForm.getManagerId(),
                deployApplyForm.getCompanyId(),
                deployApplyForm.getDepartmentId(),
                deployApplyForm.getPostId(),
                deployApplyForm.getRoomCategoryId(),
                deployApplyForm.getSource()
        );
        deployApply.setCreator(deployApplyForm.getUserId());
        deployApply.setModifier(deployApplyForm.getUserId());
        return deployApplyDao.insert(deployApply);
    }

    @Override
    public void agreeDeploy(String spNo) {
        DeployApply deployApply = deployApplyDao.selectOne(new QueryWrapper<DeployApply>().eq("code", spNo));
        if(null != deployApply){
            deployApply.setStatus(DeployApply.Status.submitted); // 审核通过修改状态为已提交
            deployApplyDao.updateById(deployApply);
        }
    }

    @Override
    public void rejectDeploy(String spNo) {
        DeployApply deployApply = deployApplyDao.selectOne(new QueryWrapper<DeployApply>().eq("code", spNo));
        if(null != deployApply){
            deployApply.setStatus(DeployApply.Status.revoked);
            deployApplyDao.updateById(deployApply);
        }
    }

    @Override
    public void revokeDeploy(String spNo) {
        DeployApply deployApply = deployApplyDao.selectOne(new QueryWrapper<DeployApply>().eq("code", spNo));
        if(null != deployApply){
            deployApply.setStatus(DeployApply.Status.revoked);
            deployApplyDao.updateById(deployApply);
        }
    }

    @Override
    public int addCheckOutApply(CheckOutApplyForm checkOutApplyForm) {
        //校验
        CheckOutApply checkOutApply =new CheckOutApply(
                checkOutApplyForm.getCreator(),
                checkOutApplyForm.getModifier(),
                checkOutApplyForm.getIsDeleted(),
                checkOutApplyForm.getRemark(),
                checkOutApplyForm.getCode(),
                checkOutApplyForm.getUserId(),
                checkOutApplyForm.getCompanyId(),
                checkOutApplyForm.getDepartmentId(),
                checkOutApplyForm.getPostId(),
                checkOutApplyForm.getSex(),
                checkOutApplyForm.getAge(),
                checkOutApplyForm.getMaritalStatus(),
                checkOutApplyForm.getLivingTime(),
                checkOutApplyForm.getAuditStatus(),
                checkOutApplyForm.getBuildingId(),
                checkOutApplyForm.getFloorId(),
                checkOutApplyForm.getRoomCategoryId(),
                checkOutApplyForm.getRoomSnId(),
                checkOutApplyForm.getStatus(),
                checkOutApplyForm.getCheckOutTime(),
                checkOutApplyForm.getRentSettlement(),
                checkOutApplyForm.getAuditReply(),
                checkOutApplyForm.getRecyclingAuthorization(),
                checkOutApplyForm.getBedSnId(),
                checkOutApplyForm.getManagerId(),
                checkOutApplyForm.getSource()
        );
        checkOutApply.setCreator(checkOutApplyForm.getUserId());
        checkOutApply.setModifier(checkOutApplyForm.getUserId());
        return checkOutApplyDao.insert(checkOutApply);
    }

    @Override
    public void agreeCheckOut(String spNo) {
        CheckOutApply checkOutApply = checkOutApplyDao.selectOne(new QueryWrapper<CheckOutApply>().eq("code", spNo));
        if(null != checkOutApply){
            checkOutApply.setStatus(CheckOutApply.Status.checkOutCompleted); // 审核通过修改状态为退房完成
            checkOutApplyDao.updateById(checkOutApply);
        }
    }

    @Override
    public void rejectCheckOut(String spNo) {
        CheckOutApply checkOutApply = checkOutApplyDao.selectOne(new QueryWrapper<CheckOutApply>().eq("code", spNo));
        if(null != checkOutApply){
            checkOutApply.setStatus(CheckOutApply.Status.revoked);
            checkOutApplyDao.updateById(checkOutApply);
        }
    }

    @Override
    public void revokeCheckOut(String spNo) {
        CheckOutApply checkOutApply = checkOutApplyDao.selectOne(new QueryWrapper<CheckOutApply>().eq("code", spNo));
        if(null != checkOutApply){
            checkOutApply.setStatus(CheckOutApply.Status.revoked);
            checkOutApplyDao.updateById(checkOutApply);
        }
    }

}
*/
